<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('餐品周期菜单列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            日期：
                            <select name="weekendId">
                                <option value="">所有</option>
                                <option value="1">周一</option>
                                <option value="2">周二</option>
                                <option value="3">周三</option>
                                <option value="4">周四</option>
                                <option value="5">周五</option>
                                <option value="6">周六</option>
                                <option value="7">周日</option>
                            </select>
                        </li>
                        <li>
                            类目：
                            <select name="categoryId" th:with="category=${@category.getCategory(null)}">
                                <option value="">所有</option>
                                <option th:each="category : ${category}" th:text="${category.categoryName}"
                                        th:value="${category.id}"></option>
                            </select>
                        </li>

                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="wechatprogram:weekend:add">
                <i class="fa fa-plus"></i> 添加
            </a>
<!--            <a class="btn btn-primary single disabled" onclick="$.operate.edit()"-->
<!--               shiro:hasPermission="wechatprogram:weekend:edit">-->
<!--                <i class="fa fa-edit"></i> 修改-->
<!--            </a>-->
<!--            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()"-->
<!--               shiro:hasPermission="wechatprogram:weekend:remove">-->
<!--                <i class="fa fa-remove"></i> 删除-->
<!--            </a>-->
<!--            <a class="btn btn-warning" onclick="$.table.exportExcel()"-->
<!--               shiro:hasPermission="wechatprogram:weekend:export">-->
<!--                <i class="fa fa-download"></i> 导出-->
<!--            </a>-->
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('wechatprogram:weekend:edit')}]];
    var removeFlag = [[${@permission.hasPermi('wechatprogram:weekend:remove')}]];
    var prefix = ctx + "wechatprogram/weekend";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "餐品周期菜单",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '主键',
                    visible: false
                },
                {
                    field: 'weekendId',
                    title: '日期id',
                    visible: false
                },
                {
                    field: 'weekendName',
                    title: '日期名称'
                },
                {
                    field: 'categoryId',
                    title: '类目id',
                    visible: false
                },
                {
                    field: 'categoryName',
                    title: '类目名称'
                },
                {
                    field: 'menuName',
                    title: '菜品名称'
                },
                {
                    field: 'menuPictureUrl',
                    title: '菜品图片',
                    formatter: function (value, row, index) {
                        return '<img src="' + value + '" width="150" height="100">';
                    }
                },
                {
                    field: 'remark',
                    title: '备注',
                    visible: false
                },
                {
                    field: 'webId',
                    title: '站点id',
                    visible: false
                },
                {
                    field: 'del',
                    title: '删除状态',
                    visible: false
                },
                {
                    field: 'back1',
                    title: '预留字段1',
                    visible: false
                },
                {
                    field: 'back2',
                    title: '预留字段2',
                    visible: false
                },
                {
                    field: 'back3',
                    title: '预留字段3',
                    visible: false
                },
                {
                    field: 'back4',
                    title: '预留字段4',
                    visible: false
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        // actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function searchMonday() {
        var weekendId = $("#Monday").val();
        var formdata = new FormData();
        formdata.append("weekendId", weekendId);
        $.ajax({
            url: prefix + "/list",
            data: formdata,
            type: "post",
            processData: false,
            contentType: false,
            success: function (result) {
                $.operate.saveSuccess(result);
            }
        })
    }

</script>
</body>
</html>